﻿using FunctionalCLR.Core;
using System.IO;

namespace FunctionalCLR.Shell.Function.IO {

    /// <summary>
    /// buff = "";
    /// filename = "c:\\hello.txt";
    /// if(hasfile(filename), buff = read("c:\\hello.txt"));
    /// echo(buff);
    /// </summary>
    public class ReadNode : FuncNode {

        public ReadNode()
            : base() {
            base.Value = "read";
        }

        public override object Evaluate() {
            object obj = Children[0].Evaluate();
            return File.ReadAllText(obj.ToString());
        }
    }
}
